# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>

pkgname=git-repair
pkgver=1.20230814
pkgrel=22
pkgdesc="Repairs a damaged git repository"
url="https://git-repair.branchable.com/"
license=("AGPL3")
arch=('loong64' 'x86_64')
depends=('git' 'ghc-libs' 'haskell-async' 'haskell-attoparsec' 'haskell-data-default'
         'haskell-filepath-bytestring' 'haskell-hslogger' 'haskell-ifelse'
         'haskell-network' 'haskell-network-uri' 'haskell-optparse-applicative' 'haskell-quickcheck'
         'haskell-split' 'haskell-unix-compat' 'haskell-utf8-string')
makedepends=('ghc')
source=("git+https://git.joeyh.name/git/$pkgname.git?signed#tag=$pkgver")
sha512sums=('SKIP')
validpgpkeys=('E85A5F63B31D24C1EBF0D81CC910D9222512E3C7')

build() {
  cd git-repair

  runhaskell Setup configure -O --prefix=/usr --enable-executable-dynamic --disable-library-vanilla \
    --docdir="/usr/share/doc/$pkgname" --ghc-option='-pie'
  runhaskell Setup build $MAKEFLAGS
}

package() {
  cd git-repair
  runhaskell Setup copy --destdir="$pkgdir"
  install -Dm644 git-repair.1 "$pkgdir"/usr/share/man/man1/git-repair.1

  rm "$pkgdir"/usr/share/doc/git-repair/COPYRIGHT
  rmdir "$pkgdir"/usr/share/doc/git-repair "$pkgdir"/usr/share/doc
}
